home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / perl5 / Term::Cap.z / Term::Cap
Encoding:
Text File  |  2002-10-03  |  4.9 KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTeeeerrrrmmmm::::::::CCCCaaaapppp((((3333))))                                                      TTTTeeeerrrrmmmm::::::::CCCCaaaapppp((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Term::Cap - Perl termcap interface
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          require Term::Cap;
  13.          $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
  14.          $terminal->Trequire(qw/ce ku kd/);
  15.          $terminal->Tgoto('cm', $col, $row, $FH);
  16.          $terminal->Tputs('dl', $count, $FH);
  17.          $terminal->Tpad($string, $count, $FH);
  18.  
  19.  
  20. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.      These are low-level functions to extract and use capabilities from a
  22.      terminal capability (termcap) database.
  23.  
  24.      The TTTTggggeeeetttteeeennnntttt function extracts the entry of the specified terminal type
  25.      _T_E_R_M (defaults to the environment variable _T_E_R_M) from the database.
  26.  
  27.      It will look in the environment for a _T_E_R_M_C_A_P variable.  If found, and
  28.      the value does not begin with a slash, and the terminal type name is the
  29.      same as the environment string _T_E_R_M, the _T_E_R_M_C_A_P string is used instead
  30.      of reading a termcap file.  If it does begin with a slash, the string is
  31.      used as a path name of the termcap file to search.  If _T_E_R_M_C_A_P does not
  32.      begin with a slash and name is different from _T_E_R_M, TTTTggggeeeetttteeeennnntttt searches the
  33.      files $_H_O_M_E/._t_e_r_m_c_a_p, /_e_t_c/_t_e_r_m_c_a_p, and /_u_s_r/_s_h_a_r_e/_m_i_s_c/_t_e_r_m_c_a_p, in that
  34.      order, unless the environment variable _T_E_R_M_P_A_T_H exists, in which case it
  35.      specifies a list of file pathnames (separated by spaces or colons) to be
  36.      searched iiiinnnnsssstttteeeeaaaadddd.  Whenever multiple files are searched and a tc field
  37.      occurs in the requested entry, the entry it names must be found in the
  38.      same file or one of the succeeding files.  If there is a :tc=...: in the
  39.      _T_E_R_M_C_A_P environment variable string it will continue the search in the
  40.      files as above.
  41.  
  42.      _O_S_P_E_E_D is the terminal output bit rate (often mistakenly called the baud
  43.      rate).  _O_S_P_E_E_D can be specified as either a POSIX termios/SYSV termio
  44.      speeds (where 9600 equals 9600) or an old BSD-style speeds (where 13
  45.      equals 9600).
  46.  
  47.      TTTTggggeeeetttteeeennnntttt returns a blessed object reference which the user can then use to
  48.      send the control strings to the terminal using TTTTppppuuuuttttssss and TTTTggggoooottttoooo.  It calls
  49.      croak on failure.
  50.  
  51.      TTTTggggoooottttoooo decodes a cursor addressing string with the given parameters.
  52.  
  53.      The output strings for TTTTppppuuuuttttssss are cached for counts of 1 for performance.
  54.      TTTTggggoooottttoooo and TTTTppppaaaadddd do not cache.  $self->{_xx} is the raw termcap data and
  55.      $self->{xx} is the cached version.
  56.  
  57.          print $terminal->Tpad($self->{_xx}, 1);
  58.  
  59.      TTTTggggoooottttoooo, TTTTppppuuuuttttssss, and TTTTppppaaaadddd return the string and will also output the string
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTeeeerrrrmmmm::::::::CCCCaaaapppp((((3333))))                                                      TTTTeeeerrrrmmmm::::::::CCCCaaaapppp((((3333))))
  71.  
  72.  
  73.  
  74.      to $FH if specified.
  75.  
  76.      The extracted termcap entry is available in the object as $self-
  77.      >{TERMCAP}.
  78.  
  79. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  80.          # Get terminal output speed
  81.          require POSIX;
  82.          my $termios = new POSIX::Termios;
  83.          $termios->getattr;
  84.          my $ospeed = $termios->getospeed;
  85.  
  86.          # Old-style ioctl code to get ospeed:
  87.          #     require 'ioctl.pl';
  88.          #     ioctl(TTY,$TIOCGETP,$sgtty);
  89.          #     ($ispeed,$ospeed) = unpack('cc',$sgtty);
  90.  
  91.          # allocate and initialize a terminal structure
  92.          $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
  93.  
  94.          # require certain capabilities to be available
  95.          $terminal->Trequire(qw/ce ku kd/);
  96.  
  97.          # Output Routines, if $FH is undefined these just return the string
  98.  
  99.          # Tgoto does the % expansion stuff with the given args
  100.          $terminal->Tgoto('cm', $col, $row, $FH);
  101.  
  102.          # Tputs doesn't do any % expansion.
  103.          $terminal->Tputs('dl', $count = 1, $FH);
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.